package cn.yuanqiao.web.controller.archive.appManager;

import cn.yuanqiao.archive.appManager.domain.YqSy;
import cn.yuanqiao.archive.appManager.service.IYqSyService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.web.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 水印Controller
 *
 * @author yuanqiao
 * @date 2023-06-16
 */
@RestController
@RequestMapping(path = {"/manage/yqSy","/archive/yqSy"})
public class YqSyController extends BaseController
{
    @Autowired
    private IYqSyService yqSyService;

    /**
     * 查询水印列表
     */
    @PreAuthorize("@ss.hasAnyPermi('archive:yqSy:list,tenantManage:templateManage:yqSy:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqSy yqSy)
    {
        startPage();
        List<YqSy> list = yqSyService.selectYqSyList(yqSy);
        return getDataTable(list);
    }

    /**
     * 导出水印列表
     */
//    @PreAuthorize("@ss.hasPermi('archive:yqSy:export')")
//    @Log(title = "水印", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, YqSy yqSy)
//    {
//        List<YqSy> list = yqSyService.selectYqSyList(yqSy);
//        ExcelUtil<YqSy> util = new ExcelUtil<YqSy>(YqSy.class);
//        util.exportExcel(response, list, "水印数据");
//    }

    /**
     * 获取水印详细信息
     */
    @PreAuthorize("@ss.hasAnyPermi('archive:yqSy:query,tenantManage:templateManage:yqSy:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(yqSyService.selectYqSyByID(ID));
    }

    /**
     * 获取水印详细信息（根据水印代码）
     */
//    @PreAuthorize("@ss.hasPermi('archive:yqSy:query')")
    @GetMapping( "/sydm")
    public AjaxResult getSy(@RequestParam("sydm") String sydm)
    {
        YqSy yqSy = new YqSy();
        yqSy.setSydm(sydm);
        return success(yqSyService.selectYqSyBySydm(yqSy));
    }

    /**
     * 新增水印
     */
    @PreAuthorize("@ss.hasAnyPermi('archive:yqSy:add,tenantManage:templateManage:yqSy:add')")
    @Log(title = "水印", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody YqSy yqSy)
    {
        return success(yqSyService.insertYqSy(yqSy));
    }

    /**
     * 修改水印
     */
    @PreAuthorize("@ss.hasAnyPermi('archive:yqSy:edit,tenantManage:templateManage:yqSy:edit')")
    @Log(title = "水印", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody YqSy yqSy)
    {
        return success(yqSyService.updateYqSy(yqSy));
    }

    /**
     * 删除水印
     */
    @PreAuthorize("@ss.hasAnyPermi('archive:yqSy:remove,tenantManage:templateManage:yqSy:remove')")
    @Log(title = "水印", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(yqSyService.deleteYqSyByIDs(IDs));
    }

    /**
     * 修改水印启用状态
     */
    @PreAuthorize("@ss.hasAnyPermi('archive:yqSy:editStatus,tenantManage:templateManage:yqSy:editStatus')")
    @Log(title = "水印", businessType = BusinessType.UPDATE)
    @PutMapping("/editStatus")
    public AjaxResult editStatus(@RequestBody YqSy yqSy)
    {
        return toAjax(yqSyService.updateYqSyStatus(yqSy));
    }
}
